﻿using System;

using System.Collections;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Global.Class.Library;
using BusinessLogicLayer;
using BusinessLogicLayer.MetaDataList;
using DataAccessLayer;
using DataTransferObject;
using DataTransferObject.MetaDataList;
using System.Globalization;
using BrightIdeasSoftware;
using Equin.ApplicationFramework;

namespace PresentationLayer
{
    public partial class ListItemCommodity : Form, IMergeToolStrip, ICallToolStrip
    {

        #region <Implement Interface>

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public GlobalEnum.TaskID TaskID
        {
            get { return this.listCustomerNameBLL.TaskID; }
        }


        public ToolStrip ChildToolStrip
        {
            get
            {
                return this.toolStripChildForm;
            }
            set
            {
                this.toolStripChildForm = value;
            }
        }





        #region Context toolbar


        public bool IsDirty
        {
            get { return this.listCustomerNameBLL.IsDirty; }
        }

        public bool IsValid
        {
            get { return this.listCustomerNameBLL.IsValid; }
        }

        public bool Closable
        {
            get { return true; }
        }

        public bool Loadable
        {
            get { return true; }
        }

        public bool Newable
        {
            get { return !this.listCustomerNameBLL.ReadOnly; }
        }

        public bool Editable
        {
            get { return !this.listCustomerNameBLL.ReadOnly; }
        }

        public bool Deletable
        {
            get { return this.listCustomerNameBLL.Editable; }
        }

        public bool Importable
        {
            get { return false; }
        }

        public bool Exportable
        {
            get { return false; }
        }

        public bool Verifiable
        {
            get { return this.listCustomerNameBLL.Verifiable; }
        }

        public bool Unverifiable
        {
            get { return this.listCustomerNameBLL.Unverifiable; }
        }

        public bool Printable
        {
            get { return false; }
        }

        public bool Searchable
        {
            get { return true; }
        }

        /// <summary>
        /// Edit Mode: True, Read Mode: False
        /// </summary>
        private bool editableMode;
        private int lastCustomerNameID;
        public bool EditableMode { get { return this.editableMode; } }
        /// <summary>
        /// This reverse of the EditableMode
        /// </summary>
        public bool ReadonlyMode { get { return !this.editableMode; } }

        /// <summary>
        /// Set the editableMode
        /// </summary>
        /// <param name="editableMode"></param>
        private void SetEditableMode(bool editableMode)
        {
            if (this.editableMode != editableMode)
            {
                this.lastCustomerNameID = this.listCustomerNameBLL.CustomerID;
                this.editableMode = editableMode;
                this.NotifyPropertyChanged("EditableMode");

                this.naviGroupDetails.Expanded = editableMode;
            }
        }


        private void CancelDirty(bool restoreSavedData)
        {
            try
            {
                if (restoreSavedData || this.listCustomerNameBLL.CustomerID <= 0)
                    this.listCustomerNameBLL.Fill(this.lastCustomerNameID);

                this.SetEditableMode(false);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }



        #endregion Context toolbar



        #region ICallToolStrip

        public void Escape()
        {
            if (this.EditableMode)
            {
                if (this.IsDirty)
                {
                    DialogResult dialogResult = MessageBox.Show(this, "Do you want to save your change?", "Warning", MessageBoxButtons.YesNoCancel);
                    if (dialogResult == DialogResult.Yes)
                    {
                        this.Save();
                        if (!this.IsDirty) this.CancelDirty(false);
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                        this.CancelDirty(true);
                    }
                    else
                        return;
                }
                else
                    this.CancelDirty(false);
            }
            else
                this.Close(); //Unload this module
        }


        public void Loading()
        {
            this.GetMasterList();
        }

        public void New()
        {
            this.listCustomerNameBLL.New();
            this.SetEditableMode(true);
        }

        public void Edit()
        {
            this.SetEditableMode(true);
        }

        public void Save()
        {
            this.listCustomerNameBLL.Save();
            this.GetMasterList();
        }

        public void Delete()
        {
            DialogResult dialogResult = MessageBox.Show(this, "Are you sure you want to delete " + this.listCustomerNameBLL.ListCustomerNameMaster.Description + "?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    this.listCustomerNameBLL.Delete();
                    this.GetMasterList();
                }
                catch (Exception exception)
                {
                    GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
                }
            }
        }

        public void Import()
        {
            ImportExcel();
        }

        public void Export()
        {
            try
            {
            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
            }
        }

        public void Verify()
        {
            MessageBox.Show("Verify");
        }

        public void Print(PrintDestination printDestination)
        {
            MessageBox.Show("Print");
        }

        public void SearchText(string searchText)
        {

        }

        #endregion


        #endregion <Implement Interface>








        #region <Storage>
        private ListCustomerNameBLL listCustomerNameBLL;

        #endregion <Storage>


        public ListItemCommodity()
        {
            try
            {
                InitializeComponent();

                this.listCustomerNameBLL = new ListCustomerNameBLL();

                this.listCustomerNameBLL.PropertyChanged += new PropertyChangedEventHandler(listCustomerNameBLL_PropertyChanged);

            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
            }
        }

        void listCustomerNameBLL_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            this.NotifyPropertyChanged(e.PropertyName);
        }


        private void ListCustomerName_Load(object sender, EventArgs e)
        {
            try
            {
                InitializeCommonControlBinding();

                InitializeDataGridBinding();

                InitializeReadOnlyModeBinding();
            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
            }
        }


        #region <InitializeBinding>


        Binding customerCategoryIDBinding;
        Binding customerTypeIDBinding;
        Binding salesmenIDBinding;
        Binding addressAreaIDBinding;
        Binding customerGroupIDBinding;
        Binding customerChannelIDBinding;
        Binding masterCustomerIDBinding;

        Binding descriptionBinding;
        Binding descriptionOfficialBinding;
        Binding descriptionOriginalBinding;
        Binding vatCodeBinding;
        Binding contactNameBinding;
        Binding attentionNameBinding;
        Binding telephoneBinding;
        Binding emailAddressBinding;
        Binding addressNoBinding;
        Binding addressStreetBinding;
        Binding otherBinding;


        Binding isMasterCustomerBinding;
        Binding isTenderCustomerBinding;


        Binding isDirtyBinding;
        Binding isDirtyBLLBinding;

        private void InitializeCommonControlBinding()
        {
            CommonMetaList commonMetaList = new CommonMetaList();


            ERmgrUIP.ListCustomerCategoryDataTable listItemCustomerCategoryDataTable = commonMetaList.GetCustomerCategory();
            this.comboBoxCustomerCategoryID.DataSource = listItemCustomerCategoryDataTable;
            this.comboBoxCustomerCategoryID.DisplayMember = listItemCustomerCategoryDataTable.DescriptionColumn.ColumnName;
            this.comboBoxCustomerCategoryID.ValueMember = listItemCustomerCategoryDataTable.CustomerCategoryIDColumn.ColumnName;
            this.customerCategoryIDBinding = this.comboBoxCustomerCategoryID.DataBindings.Add("SelectedValue", this.listCustomerNameBLL.ListCustomerNameMaster, "CustomerCategoryID", true);

            ERmgrUIP.ListCustomerTypeDataTable listItemCustomerTypeDataTable = commonMetaList.GetCustomerType();
            this.comboBoxCustomerTypeID.DataSource = listItemCustomerTypeDataTable;
            this.comboBoxCustomerTypeID.DisplayMember = listItemCustomerTypeDataTable.DescriptionColumn.ColumnName;
            this.comboBoxCustomerTypeID.ValueMember = listItemCustomerTypeDataTable.CustomerTypeIDColumn.ColumnName;
            this.customerTypeIDBinding = this.comboBoxCustomerTypeID.DataBindings.Add("SelectedValue", this.listCustomerNameBLL.ListCustomerNameMaster, "CustomerTypeID", true);

            ERmgrUIP.ListSalesmenNameDataTable listItemSalesmenNameDataTable = commonMetaList.GetSalesmenName();
            this.comboBoxSalesmenID.DataSource = listItemSalesmenNameDataTable;
            this.comboBoxSalesmenID.DisplayMember = listItemSalesmenNameDataTable.DescriptionColumn.ColumnName;
            this.comboBoxSalesmenID.ValueMember = listItemSalesmenNameDataTable.SalesmenIDColumn.ColumnName;
            this.salesmenIDBinding = this.comboBoxSalesmenID.DataBindings.Add("SelectedValue", this.listCustomerNameBLL.ListCustomerNameMaster, "SalesmenID", true);

            ERmgrUIP.ListAddressAreaDataTable listItemAddressAreaDataTable = commonMetaList.GetAddressArea();
            this.comboBoxAddressAreaID.DataSource = listItemAddressAreaDataTable;
            this.comboBoxAddressAreaID.DisplayMember = listItemAddressAreaDataTable.DescriptionColumn.ColumnName;
            this.comboBoxAddressAreaID.ValueMember = listItemAddressAreaDataTable.AddressAreaIDColumn.ColumnName;
            this.addressAreaIDBinding = this.comboBoxAddressAreaID.DataBindings.Add("SelectedValue", this.listCustomerNameBLL.ListCustomerNameMaster, "AddressAreaID", true);

            ERmgrUIP.ListCustomerGroupDataTable listItemCustomerGroupDataTable = commonMetaList.GetCustomerGroup();
            this.comboBoxCustomerGroupID.DataSource = listItemCustomerGroupDataTable;
            this.comboBoxCustomerGroupID.DisplayMember = listItemCustomerGroupDataTable.DescriptionColumn.ColumnName;
            this.comboBoxCustomerGroupID.ValueMember = listItemCustomerGroupDataTable.CustomerGroupIDColumn.ColumnName;
            this.customerGroupIDBinding = this.comboBoxCustomerGroupID.DataBindings.Add("SelectedValue", this.listCustomerNameBLL.ListCustomerNameMaster, "CustomerGroupID", true);

            //ERmgrUIP.ListCustomerNameDataTable listItemCustomerNameDataTable = commonMetaList.GetCustomerName();
            //this.comboBoxCustomerID.DataSource = listItemCustomerNameDataTable;
            //this.comboBoxCustomerID.DisplayMember = listItemCustomerNameDataTable.DescriptionColumn.ColumnName;
            //this.comboBoxCustomerID.ValueMember = listItemCustomerNameDataTable.CustomerIDColumn.ColumnName;
            //this.customerCategoryIDBinding = this.comboBoxCustomerID.DataBindings.Add("SelectedValue", this.listCustomerNameBLL.ListCustomerNameMaster, "CustomerID", true);

            ERmgrUIP.ListCustomerChannelDataTable listItemCustomerChannelDataTable = commonMetaList.GetCustomerChannel();
            this.comboBoxCustomerChannelID.DataSource = listItemCustomerChannelDataTable;
            this.comboBoxCustomerChannelID.DisplayMember = listItemCustomerChannelDataTable.DescriptionColumn.ColumnName;
            this.comboBoxCustomerChannelID.ValueMember = listItemCustomerChannelDataTable.CustomerChannelIDColumn.ColumnName;
            this.customerChannelIDBinding = this.comboBoxCustomerChannelID.DataBindings.Add("SelectedValue", this.listCustomerNameBLL.ListCustomerNameMaster, "CustomerChannelID", true);


            this.descriptionBinding = this.textBoxDescription.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "Description", true);
            this.descriptionOfficialBinding = this.textBoxDescriptionOfficial.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "DescriptionOfficial", true);
            this.addressNoBinding = this.textBoxAddressNo.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "AddressNo", true);
            this.vatCodeBinding = this.textBoxVATCode.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "VATCode", true);
            this.contactNameBinding = this.textBoxContactName.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "ContactName", true);
            this.attentionNameBinding = this.textBoxAttentionName.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "AttentionName", true);
            this.telephoneBinding = this.textBoxTelephone.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "Telephone", true);
            this.emailAddressBinding = this.textBoxEMailAddress.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "EMailAddress", true);
            this.otherBinding = this.textBoxOther.DataBindings.Add("Text", this.listCustomerNameBLL.ListCustomerNameMaster, "Other", true);


            this.isDirtyBinding = this.checkBoxIsDirty.DataBindings.Add("Checked", this.listCustomerNameBLL.ListCustomerNameMaster, "IsDirty", true);
            this.isDirtyBLLBinding = this.checkBoxIsDirtyBLL.DataBindings.Add("Checked", this.listCustomerNameBLL, "IsDirty", true);



            this.customerCategoryIDBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.customerTypeIDBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.salesmenIDBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.addressAreaIDBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.customerGroupIDBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            //this.masterCustomerIDBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.customerChannelIDBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);

            this.descriptionBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.descriptionOfficialBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            //this.descriptionOriginalBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.vatCodeBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.contactNameBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.attentionNameBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.telephoneBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.emailAddressBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.addressNoBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            //this.addressStreetBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.otherBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);


            //this.isMasterCustomerBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            //this.isTenderCustomerBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);


            this.isDirtyBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);
            this.isDirtyBLLBinding.BindingComplete += new BindingCompleteEventHandler(CommonControl_BindingComplete);

            this.numericUpDownSizingDetail.Value = 300;

            this.naviGroupDetails.DataBindings.Add("ExpandedHeight", this.numericUpDownSizingDetail, "Value", true, DataSourceUpdateMode.OnPropertyChanged);
            this.numericUpDownSizingDetail.Minimum = this.naviGroupDetails.HeaderHeight * 2;
            this.numericUpDownSizingDetail.Maximum = this.naviGroupDetails.Height + this.dataTreeListViewMaster.Height;


            this.errorProviderMaster.DataSource = this.listCustomerNameBLL.ListCustomerNameMaster;
        }


        private void CommonControl_BindingComplete(object sender, BindingCompleteEventArgs e)
        {
            if (e.BindingCompleteState == BindingCompleteState.Exception) { GlobalExceptionHandler.ShowExceptionMessageBox(this, e.ErrorText); e.Cancel = true; }
        }

        private void numericUpDownSizingDetail_ValueChanged(object sender, EventArgs e)
        {
            this.naviGroupDetails.Expand();
        }

        private void naviGroupDetails_HeaderMouseClick(object sender, MouseEventArgs e)
        {
            this.numericUpDownSizingDetail.Visible = this.naviGroupDetails.Expanded;
        }

        

        private void InitializeDataGridBinding()
        {

            this.GetMasterList();



            #region <dataGridViewDetail>


            this.dataGridViewListCustomerNameDetail.AutoGenerateColumns = false;
            listCustomerNameDetailView = new BindingListView<ListCustomerNameDetail>(this.listCustomerNameBLL.ListCustomerNameDetailList);
            this.dataGridViewListCustomerNameDetail.DataSource = listCustomerNameDetailView;

            StackedHeaderDecorator stackedHeaderDecorator = new StackedHeaderDecorator(this.dataGridViewListCustomerNameDetail);

            this.dataGridViewListCustomerNameSalesmen.AutoGenerateColumns = false;
            listCustomerNameSalesmenView = new BindingListView<ListCustomerNameSalesmen>(this.listCustomerNameBLL.ListCustomerNameSalesmenList);
            this.dataGridViewListCustomerNameSalesmen.DataSource = listCustomerNameSalesmenView;

            StackedHeaderDecorator stackedHeaderDecorator1 = new StackedHeaderDecorator(this.dataGridViewListCustomerNameSalesmen);

            DataGridViewComboBoxColumn comboBoxColumn;
            CommonMetaList commonMetaList = new CommonMetaList();

            ERmgrUIP.ListSalesmenNameDataTable listItemSalesmenNameDataTable = commonMetaList.GetSalesmenName(true);
            comboBoxColumn = (DataGridViewComboBoxColumn)this.dataGridViewListCustomerNameSalesmen.Columns[listItemSalesmenNameDataTable.SalesmenIDColumn.ColumnName];
            comboBoxColumn.DataSource = listItemSalesmenNameDataTable;
            comboBoxColumn.DisplayMember = listItemSalesmenNameDataTable.SalesmenIDColumn.ColumnName;
            comboBoxColumn.ValueMember = listItemSalesmenNameDataTable.SalesmenIDColumn.ColumnName;

            comboBoxColumn = (DataGridViewComboBoxColumn)this.dataGridViewListCustomerNameSalesmen.Columns["SalesmenName"];
            comboBoxColumn.DataSource = listItemSalesmenNameDataTable;
            comboBoxColumn.DisplayMember = listItemSalesmenNameDataTable.DescriptionColumn.ColumnName;
            comboBoxColumn.ValueMember = listItemSalesmenNameDataTable.SalesmenIDColumn.ColumnName;

            #endregion <dataGridViewDetail>
        }


        private void InitializeReadOnlyModeBinding()
        {
            List<Control> controlList = GlobalStaticFunction.GetAllControls(this);

            foreach (Control control in controlList)
            {
                //if (control is TextBox) control.DataBindings.Add("Readonly", this, "ReadonlyMode");
                if (control is TextBox) control.DataBindings.Add("Enabled", this, "EditableMode");
                else if (control is ComboBox || control is DateTimePicker) control.DataBindings.Add("Enabled", this, "EditableMode");
                else if (control is DataGridView)
                {
                    control.DataBindings.Add("Readonly", this, "ReadonlyMode");
                    control.DataBindings.Add("AllowUserToAddRows", this, "EditableMode");
                    control.DataBindings.Add("AllowUserToDeleteRows", this, "EditableMode");
                }
            }

            this.dataTreeListViewMaster.DataBindings.Add("Enabled", this, "ReadonlyMode");
        }

        BindingListView<ListCustomerNameDetail> listCustomerNameDetailView;
        BindingListView<ListCustomerNameSalesmen> listCustomerNameSalesmenView;


        private enum CustomerNameListingOptions
        {
            AddressArea = 1,
            CustomerCategory = 2,
            CustomerChannel = 3,
            CustomerType = 4,
            MasterCustomer = 5
        }

        private void GetMasterList()
        {
            //DataTable listCustomerNameListingDataTable;

            //CustomerNameListingOptions customerNameListingOptions = this.radioButtonAddressArea.Checked ? CustomerNameListingOptions.AddressArea : (this.radioButtonCustomerCategory.Checked ? CustomerNameListingOptions.CustomerCategory : (this.radioButtonCustomerChannel.Checked ? CustomerNameListingOptions.CustomerChannel : (this.radioButtonCustomerType.Checked ? CustomerNameListingOptions.CustomerType : (this.radioButtonMasterCustomer.Checked ? CustomerNameListingOptions.MasterCustomer : CustomerNameListingOptions.AddressArea))));
            //switch (customerNameListingOptions)
            //{
            //    case CustomerNameListingOptions.AddressArea:
            //        listCustomerNameListingDataTable = this.listCustomerNameBLL.CustomerNameAddressAreaListing();
            //        break;
            //    case CustomerNameListingOptions.CustomerCategory:
            //        listCustomerNameListingDataTable = this.listCustomerNameBLL.CustomerNameCustomerCategoryListing();
            //        break;
            //    case CustomerNameListingOptions.CustomerChannel:
            //        listCustomerNameListingDataTable = this.listCustomerNameBLL.CustomerNameCustomerChannelListing();
            //        break;
            //    case CustomerNameListingOptions.CustomerType:
            //        listCustomerNameListingDataTable = this.listCustomerNameBLL.CustomerNameCustomerTypeListing();
            //        break;
            //    case CustomerNameListingOptions.MasterCustomer:
            //        listCustomerNameListingDataTable = this.listCustomerNameBLL.CustomerNameMasterCustomerListing();
            //        break;
            //    default:
            //        listCustomerNameListingDataTable = this.listCustomerNameBLL.CustomerNameAddressAreaListing();
            //        break;
            //}

            //listCustomerNameListingDataTable.TableName = "ListCustomerNameListingDataTable";

            //DataSet bindingDataSet = new DataSet();
            //bindingDataSet.Tables.Add(listCustomerNameListingDataTable);

            //this.dataTreeListViewMaster.FullRowSelect = true;
            //this.dataTreeListViewMaster.KeyAspectName = "CustomerID";
            //this.dataTreeListViewMaster.ParentKeyAspectName = "AncestorID";
            //this.dataTreeListViewMaster.RootKeyValue = 0;

            //this.dataTreeListViewMaster.DataMember = "ListCustomerNameListingDataTable";
            //this.dataTreeListViewMaster.DataSource = new DataViewManager(bindingDataSet);

            //this.dataTreeListViewMaster.ExpandAll();
        }

        #endregion <InitializeBinding>





        #region Import Excel

        private void ImportExcel()
        {
            try
            {

            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
            }

        }
        #endregion Import Excel



        private void dataTreeListViewMaster_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                ObjectListView objectListView = (ObjectListView)sender;
                DataRowView row = (DataRowView)objectListView.SelectedObject;

                if (row != null)
                {
                    int customerTypeID;

                    if (int.TryParse(row.Row["CustomerID"].ToString(), out customerTypeID)) this.listCustomerNameBLL.Fill(customerTypeID);
                    else this.listCustomerNameBLL.Fill(0);
                }
                else this.listCustomerNameBLL.Fill(0);
            }
            catch (Exception exception)
            {
                GlobalExceptionHandler.ShowExceptionMessageBox(this, exception);
            }
        }

        private void dataTreeListViewMaster_DoubleClick(object sender, EventArgs e)
        {
            this.naviGroupDetails.Expanded = true;
        }

        private void dataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            GlobalExceptionHandler.ShowExceptionMessageBox(this, e.Exception);
        }

        private void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (((RadioButton)sender).Checked)
                this.GetMasterList();
        }

    }




}
